/**
 * 删除
 * @param id
 * @param url
 */
function del(id,url){
	layer.confirm('你确定要删除吗？',{
		btn:['确定','取消']
	},function(){
		$.ajax({
			type:"post",
			url:url,
			data:{"id":id},
			dataType:"json",
			success:function(e){
				if(e.code==200){
					layer.msg(e.msg,{time:1000},function(){location.href=e.url});
				}else{
					layer.msg(e.msg);
				}
			},error:function(){
				layer.msg('网络错误');
			}
		})
	})
}
/**
 * 关闭、开启
 * 
 * */
function closethis(id,url){
	layer.confirm('你确定要执行此操作吗？',{
		btn:['确定','取消']
	},function(){
		$.ajax({
			type:"post",
			url:url,
			data:{"id":id},
			dataType:"json",
			success:function(e){
				if(e.code==200){
					layer.msg(e.msg,{time:1000},function(){location.href=e.url});
				}else{
					layer.msg(e.msg);
				}
			},error:function(){
				layer.msg('网络错误');
			}
		})
	})
}
/***
 * 下拉框选择
 */ 
function selectchange(url,oneid,twoid,circleurl){
	var one = $("#"+oneid).val();
	var two = $("#"+twoid);
	$.ajax({
		type:"post",
		url:url,
		data:{"id":one},
		dataType:"json",
		success:function(e){
			if(e.code==200){
				two.empty().append('<option value="">请选择</option>');
				var f = e['msg'];
				for(var i in f ){
					two.append('<option value="'+f[i].id+'">'+f[i].name+'</option>');
				}
				if(circleurl){
					selectcircle(circleurl,oneid);
				}
			}else{
				layer.msg(e.msg);
			}
		},error:function(){
			layer.msg('网络错误');
		}
	})
}
/**
 * 根据城市来获取商圈
 */
function selectcircle(url,city){
	var twoo = $("#circle_id");
	var citysid = $("#"+city).val();
	$.ajax({
		type:"post",
		url:url,
		data:{"citysid":citysid},
		dataType:"json",
		success:function(e){
			if(e.code==200){
				twoo.empty().append('<option value="">请选择</option>');
				var d = e['msg'];
				for(var i in d){
					twoo.append('<option value="'+d[i].id+'">'+d[i].name+'</option>');
				}
			}else{
				layer.msg(e.msg);
			}
		},error:function(){
			layer.msg('网络错误');
		}
	})
}
/**
 * 获取某个模块的所有控制器
 */
function getAction(that,url){
	var twoo = $("#actionname");
	$.ajax({
		type:"post",
		url:url,
		data:{"tpl":that},
		dataType:"json",
		success:function(e){
			if(e.code==200){
				twoo.empty().append('<option value="">请选择</option>');
				var d = e['msg'];
				for(var i in d){
					twoo.append('<option value="'+d[i]+'">'+d[i]+'</option>');
				}
			}else{
				layer.msg(e.msg);
			}
		},error:function(){
			layer.msg('网络错误');
		}
	})
}
/**
 * 升序、降序
 */
function sortthis(id,url,type,that){
	$.ajax({
		type:"post",
		url:url,
		data:{"id":id,"type":type},
		dataType:"json",
		success:function(e){
			if(e.code==200){
				that.parents("tr").find("td").eq(2).text(e.msg);
			}else{
				layer.msg(e.msg);
			}
		},error:function(){
			layer.msg('网络错误');
		}
	})
}

/**
 * 审核
 */
layer.config({
    extend: 'extend/layer.ext.js'
}); 
function shenke(that,aid,url){
	var f = layer.confirm('是否通过审核??', {
		title:'审核',
		skin:'layui-layer-molv',
		closeBtn:false,
	    btn: ['不通过','通过','取消'] //按钮
	}, function(){
	  layer.prompt({title:"请输入不通过理由",formType: 2} ,function (dd){
	    	$.ajax({
		    	type:"post",
		    	url:url,
		    	data:{"id":aid,"type":1,"reason":dd},
		    	dataType:"json",
		    	success:function(e){
		    		if(e.code == 200){
		    			layer.msg(e.msg,{time:1000},function(){location.reload();})
		    		}else{
		    			layer.msg("操作失败");
		    		}
		    	},error:function(){
		    		layer.msg('网络错误');
		    	}
		    })
	    }); 
	}, function (){
		$.ajax({
			type:"post",
			url:url,
			data:{"id":aid,"type":2},
			dataType:"json",
			success:function(e){
				if(e.code == 200){
					layer.msg(e.msg,{time:1000},function(){location.reload();})
				}else{
					layer.msg("操作失败");
				}
			},error:function(){
				layer.msg('网络错误');
			}
		})
	}, function (){
	});
}
/**
 * 重置密码
 */
function resetpass(that,aid,url){
	var f = layer.confirm('是否重置密码??', {
		title:'重置密码',
		skin:'layui-layer-molv',
		closeBtn:false,
	    btn: ['重置','取消'] //按钮
	},function(){
		layer.prompt({title:"请输入新的密码",formType: 1} ,function (dd){
	    	$.ajax({
		    	type:"post",
		    	url:url,
		    	data:{"id":aid,"pass":dd},
		    	dataType:"json",
		    	success:function(e){
		    		if(e.code == 200){
		    			layer.msg(e.msg,{time:1000},function(){location.reload();})
		    		}else{
		    			layer.msg(e.msg);
		    		}
		    	},error:function(){
		    		layer.msg('网络错误');
		    	}
		    })
	    }); 
	})
}
